<template>
<h2>房号列表</h2>
<input type="button" value="导出数据" class="btn btn-success" @click="Execport"/> 
<table class="table table-bordered">
    <thead>
        <tr>
            <td>房间号码</td>
            <td>房间楼层</td>
            <td>状态</td>
        </tr>
    </thead>
    <tbody>
        <tr v-for="item in info">
            <td>{{ item.numname }}</td>
            <td>{{ item.floor }}楼</td>
            <td>{{ item.state?"启用":"禁用" }}</td>
        </tr>
    </tbody>
</table>
</template>
<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'


const info=ref([{
    numid:0,
    numname:'',
    floor:'',
    state:true
}])
onMounted(()=>{
    axios.get('https://localhost:7173/api/Room/RoomNumShow')
    .then(res=>{
        info.value=res.data
    })
    .catch(err=>{
        console.log(err)
    })
})


const Execport=()=>{
    axios.get('https://localhost:7173/api/Room/ExecportFile',{
        params:{
            pathname:'C:\\Users\\Lenovo\\Desktop\\导出\\RoomNum.xlsx'
        }
    })
    .then(res=>{
        if(res.data>0){
            alert('导出成功')
        }
        else{
            alert('导出失败')
        }
    })
    .catch(err=>{
        console.log(err)
    })
}


</script>